import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class DebugWindow extends JDialog implements ActionListener {

	public static JList listBox;
	public static DefaultListModel listm;
	public static JScrollPane sPane;
	public static JButton closeButton;
	public static JLabel background;
	
	public static ImageIcon close_button_up;
	public static ImageIcon close_button_down;
	public static ImageIcon bgimage;
	
	public DebugWindow(JFrame parent)
	{
		setLayout(null);
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		setSize(600,410);
		
		listm = new DefaultListModel();
		listBox = new JList(listm);
		sPane = new JScrollPane(listBox);
		closeButton = new JButton();
		background = new JLabel();
		
		close_button_up = new ImageIcon("images/closewin_button_up.jpg");
		close_button_down = new ImageIcon("images/closewin_button_down.jpg");
		bgimage = new ImageIcon("images/debugbg.jpg");
		
		closeButton.setIcon(close_button_up);
		closeButton.setPressedIcon(close_button_down);
		closeButton.setBorderPainted(false);
		
		listBox.setForeground(Color.WHITE);
		listBox.setBackground(Color.BLACK);
		listBox.setBorder(null);
		
		sPane.setBorder(null);
		sPane.setAutoscrolls(true);
		
		background.setIcon(bgimage);
		
		closeButton.setBounds(455,5,120,120);
		background.setBounds(0,0,600,400);
		sPane.setBounds(40, 150, 515, 200);
		
		closeButton.addActionListener(this);
		
		add(sPane);
		add(closeButton);
		add(background);
		
		setVisible(true);
	}
	
	
	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		
		JButton button = (JButton)arg0.getSource();
		
		if(button == closeButton)
		{
			dispose();
		}
	}
	
	public void addLine(String input)
	{
		listm.addElement(input);
		listBox.ensureIndexIsVisible(listm.getSize()-1);
	}

}
